package com.xhtt.smart.card.client.init;

import com.xhtt.smart.card.client.code.MessageClientDecoder;
import com.xhtt.smart.card.client.code.MessageClientEncoder;
import com.xhtt.smart.card.client.handle.ClientHandle;
import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;
import io.netty.handler.timeout.IdleStateHandler;

/**
 * @author wangze
 * @date 2018-07-04 15:19.
 **/
public class NettyClientInit extends ChannelInitializer<Channel> {


    @Override
    protected void initChannel(Channel channel) throws Exception {
        channel.pipeline()
                //60秒发送心跳
                .addLast(new IdleStateHandler(0, 10, 0))
                //.addLast(new HeartbeatEncode())
                .addLast(new MessageClientEncoder())
                .addLast(new MessageClientDecoder())
                .addLast(new ClientHandle());
    }
}
